package client.comm.baoding.adapter

import android.content.Context
import android.content.Intent
import androidx.recyclerview.widget.DiffUtil
import client.comm.commlib.base.BasePagingAdapter
import client.comm.commlib.base.PagingViewHoder
import client.comm.baoding.R
import client.comm.baoding.api.bean.GoodsIndex
import client.comm.baoding.ui.GoodsDetailActivity
import client.comm.baoding.ui.GoodsDetailTradeActivity
import com.bumptech.glide.RequestManager

class NewSyAdapter(val context: Context, val manager: RequestManager) :
    BasePagingAdapter<GoodsIndex.TjGoods>(object : DiffUtil.ItemCallback<GoodsIndex.TjGoods>() {
        override fun areItemsTheSame(
            oldItem: GoodsIndex.TjGoods,
            newItem: GoodsIndex.TjGoods
        ): Boolean {
            return oldItem.goods_id == newItem.goods_id
        }

        override fun areContentsTheSame(
            oldItem: GoodsIndex.TjGoods,
            newItem: GoodsIndex.TjGoods
        ): Boolean {
            return oldItem == newItem
        }
    }) {

    override fun getItemLayout(): Int {
        return R.layout.layout_syitem
    }

    override fun bindItem(holder: PagingViewHoder, t: Any) {
//        val binding = holder.binding as LayoutSyitemBinding
//        binding.event2 = this
//        val bean = t as GoodsIndex.TjGoods
//        binding.bean = bean
//        manager.load(bean.goods_img)
//            .into(binding.img)
    }

    //商品详情12
    fun itemClick(bean: GoodsIndex.TjGoods) {
//        if (bean.is_type == 1) {
//            context.startActivity(Intent(context, GoodsDetailTradeActivity::class.java).apply {
//                putExtra("goodsId", "${bean.goods_id}")
//            })
//        } else {
            context.startActivity(Intent(context, GoodsDetailActivity::class.java).apply {
                putExtra("goodsId", "${bean.goods_id}")
            })
//        }

    }

}